package ${project.basePkg}.${model.module}.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import lombok.Data;

<#list imports as import>
import ${import};
</#list>
import java.io.Serializable;

/**
 * ${model.name}实体对象
 *
 * @author ${model.author}
 * @date ${.now?date?string["yyyy/MM/dd"]}
 */
@Data
@TableName("${model.tableName}")
public class ${model.code} implements Serializable {

    /**
     * 序列号
     */
    private static final long serialVersionUID = 1L;

    <#list properties as property>
    /**
     * ${property.fieldLabel}
     */
    <#-- 设置Long类型JSON序列化为String，解决前端大数精度丢失问题 -->
    <#if property.fieldType == 'Long' && property.fieldName != 'deleted'>
    @JsonSerialize(using = ToStringSerializer.class)
    </#if>
    <#if property.fieldName == 'id'>
    <#-- 为ID字段设置填值策略，同时设置JSON序列化为String，解决前端大数精度丢失问题 -->
    @TableId(type = IdType.ASSIGN_ID)
    <#elseif property.fieldName == 'deleted'>
    <#-- 逻辑删除字段，0表示未删除，同时删除时将deleted字段设值为实体对象ID，以避免实现唯一索引不好设置的问题 -->
    @TableLogic(value = "0", delval = "id")
    </#if>
    private ${property.fieldType} ${property.fieldName};

    </#list>
}